﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script type="text/javascript">
        var str = window.location.search;
        var arr = str.split("=");
        var method = arr[1].substr(0, arr[1].indexOf('&'));
        var pino = arr[2].substr(0, arr[2].indexOf('&'));
        $.ajax({
            url: "../data/system.aspx?method=" + method,
            async: false,
            success: function (text) {
                if (text == "no")
                    window.location = "../system/error.html";
                else if (text == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                    var tabs = parent.mini.get("mainTabs");
                    var tab = tabs.getTab("tab$" + method);
                    tabs.removeTab(tab);
                }
            }
        });
    </script>
</head>
<body>
    <div class="mini-toolbar" style="border-bottom: 0;">
        <table>
            <tr>
                <td><div id="piname"></div></td>
                <td>
                    <a class="mini-button" iconcls="icon-search" plain="true" onclick="search();">查询</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-add" plain="true" onclick="sendRow()">发送短信</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-fit" >
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowresize="true"
            idfield="id" multiselect="true" url="../data/system.aspx?method=GetMobileMsgList" sizeList="[15,20,50,100]" pageSize="15">
            <div property="columns">
                <div type="indexcolumn"></div>
                <div field="mm_title" width="120px" headeralign="center" align="center" allowsort="true">
                    短信息标题</div>
                <div field="mm_memo" headeralign="center" align="center" allowsort="true">
                    短信息内容</div>
                <div field="mm_sendtime" width="120px" headeralign="center" align="center" allowsort="true" dateFormat="yyyy-MM-dd HH:mm:ss">
                    发送时间</div>
                <div field="su_login" width="120px" headeralign="center" align="center" allowsort="true">
                    发送人</div>
            </div>
        </div>
    </div>
    <div id="editWindow" class="mini-window" title="手机短信" style="width: 400px;" showmodal="true"
        allowresize="false" allowdrag="true" showFooter="true">
        <div id="editform" class="form">
            <input class="mini-hidden" name="pi_no" />
            <table style="width: 98%; height: 100%;">
                <tr style="height: 20px">
                    <td class="tdtitle" style="width: 60px;">
                        <span class="red">*</span>标题：
                    </td>
                    <td class="tdtext">
                        <input name="mm_title" class="mini-textbox" style="width:300px;" required="true"/>
                    </td>
                </tr>
                <tr style="height: 20px">
                    <td class="tdtitle">
                        <span class="red">*</span>内容：
                    </td>
                    <td class="tdtext">
                        <input class="mini-textarea" name="mm_memo" width="300px" height="100px" required="true"/>
                    </td>
                </tr>
            </table>
        </div>
        <div property="footer" style="text-align:center;padding:5px;">
            <a class="mini-button" style="width:60px;" onclick="updateRow()">保存</a>
            <span style="display:inline-block;width:25px;"></span>
            <a class="mini-button" style="width:60px;" onclick="closewin()">关闭</a>
        </div>
    </div>
    <script type="text/javascript">
        $.ajaxSetup({
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            complete: function (XMLHttpRequest, textStatus) {
                if (XMLHttpRequest.responseText == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                }
            }
        });

        mini.parse();

        $.ajax({
            url: "../data/system.aspx?method=GetPersonName",
            async: false,
            data: { id: pino },
            success: function (text) {
                $("#piname").html("求职者：<font color='Blue'>" + text + "</font>");
                mini.getbyName("pi_no").setValue(pino);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                ShowMessage("系统提示", "页面加载失败！", 3);
            }
        });

        var grid = mini.get("datagrid1");
        search();

        function search() {
            grid.load({ pino: pino });
            grid.sortBy("rp_no", "desc");
        }

        function addRow() {
            var form = new mini.Form("#editform");
            form.loading();
            form.unmask();
            var win = mini.get("editWindow");
            win.setTitle("新增手机短信<span class='red'>( 带 * 号的必须填写)</span>");
            if (!win.visible)
                win.show();
        }

        function sendRow() {
            mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '保存中，请稍后...' });
            $.ajax({
                url: "../data/system.aspx?method=SendMobileMsg",
                type: "Post",
                data: { id: pino },
                success: function (ret) {
                    mini.unmask(document.body);
                    if (ret == "out") {
                        var loginWindow = parent.mini.get("loginWindow");
                        if (!loginWindow.visible)
                            loginWindow.show();
                        return;
                    }
                    if (ret >= 0) {
                        ShowMessage("系统提示", "手机短信发送成功！", 1);
                        grid.reload();
                    }
                    else
                        ShowMessage("系统提示", "手机短信发送失败！", 3);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    mini.unmask(document.body);
                    ShowMessage("系统提示", "手机短信发送失败！", 3);
                }
            });
        }

        function updateRow() {
            var form = new mini.Form("#editform");
            form.validate();
            if (form.isValid() == false)
                return;
            var o = form.getData();
            var json = mini.encode(o);

            mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '保存中，请稍后...' });
            $.ajax({
                url: "../data/system.aspx?method=SaveMobileMsg",
                type: "Post",
                data: { data: json},
                success: function (ret) {
                    mini.unmask(document.body);
                    if (ret == "out") {
                        var loginWindow = parent.mini.get("loginWindow");
                        if (!loginWindow.visible)
                            loginWindow.show();
                        return;
                    }
                    var editWindow = mini.get("editWindow");
                    if (ret >= 0) {
                        editWindow.hide();
                        ShowMessage("系统提示", "手机短信发送成功！", 1);
                        grid.reload();
                    }
                    else
                        ShowMessage("系统提示", "手机短信发送失败！", 3);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    mini.unmask(document.body);
                    ShowMessage("系统提示", "手机短信发送失败！", 3);
                }
            });
        }

        function closewin() {
            var win = mini.get("editWindow");
            win.hide();
        }

        function CloseWindow(action) {
            window.CloseOwnerWindow("ok");
            var tabs = parent.mini.get("mainTabs");
            var tab = tabs.getTab("tab$" + method);
            tab.enabled = true;
            var iframe = tabs.getTabIFrameEl(tab);
            iframe.contentWindow.search();
            tabs.activeTab(tab);
        }
    </script>
</body>
</html>